package models

import (
	"time"
)

type UserGrade struct {
	ID                  int       `gorm:"primary_key" json:"id"`
	UserId              int       `json:"user_id"`
	LastMoney           float64   `json:"last_money"`
	VipFeeConfigId      int       `json:"vip_fee_config_id"`
	vipFeeConfigComment string    `json:"vip_fee_config_comment"`
	CreatedAt           time.Time `json:"created_at"`
	UpdatedAt            time.Time `json:"updated_at"`
	OveredAt            time.Time `json:"overed_at"`
	LastAt              time.Time `json:"last_at"`
}

func (u *UserGrade) TableName() string {
	return "user_grade"
}

// 获取用户等级表用户一条信息
func (u *UserGrade) GetUserGradeInfoById() (*UserGrade, error) {
	var user_grade UserGrade

	err := DB.Model(u).Where("user_id=?", u.ID).Find(&user_grade).Error
	if err != nil {
		return nil, err
	}
	return &user_grade, nil
}
